import { stringify } from 'qs';
import request from '../utils/request';

export async function queryGameList(params) {
  const { phaseCode, headers } = params;
  if (headers) {
    headers['x-sort-by'] = 'id';
    headers['x-order'] = 'desc';
  }
  return request(`/gameInfo/`, {
    headers: headers
      ? headers
      : { 'x-page-num': 1, 'x-page-size': 20, 'x-sort-by': 'id', 'x-order': 'desc' },
    method: 'GET',
  });
}

export async function addGame(params) {
  return request('/gameInfo/', {
    method: 'POST',
    body: params,
  });
}

export async function modifyGame(params) {
  return request(`/gameInfo/`, {
    method: 'PATCH',
    body: params,
  });
}

export async function changeStatus(params) {
  return request('/gameInfo/', {
    method: 'PATCH',
    body: params,
  });
}

export async function findById(id) {
  return request('/gameInfo/' + id, {
    method: 'GET',
  });
}

export async function removeGameRole(id) {
  return request(`/gameInfo/removeGameRole?gameId=${id}`, {
    method: 'DELETE',
  });
}
